Skip to content

fix(world-map): exclude null and zero metric values from color scale#39926

Open
massucattoj wants to merge 1 commit intoapache:masterfrom
massucattoj:fix/world-map-exclude-null-zero-metrics
Open

fix(world-map): exclude null and zero metric values from color scale#39926
massucattoj wants to merge 1 commit intoapache:masterfrom
massucattoj:fix/world-map-exclude-null-zero-metrics

Conversation

@massucattoj
Copy link
Copy Markdown
Contributor

SUMMARY

When using the World Map chart with Color by: Metric, countries with a
metric value of NULL or 0 were assigned a color from the linear scale
instead of being treated as "no data". NULL values often ended up rendered
in the darkest shade of the palette, misleadingly suggesting a maximum
value, while 0 values were colored as the scale minimum. Both should be
indistinguishable from countries that don't appear in the dataset (rendered
in the default grey).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
image

After:
Screenshot 2026-05-06 at 23 00 26

TESTING INSTRUCTIONS

  1. Open SQL Lab and run:
    SELECT 'United States' AS country, 100 AS metric
    UNION ALL SELECT 'Canada', NULL
    UNION ALL SELECT 'Mexico', 0
  2. Save as a virtual dataset (e.g. world_map_repro).
  3. Create a new chart on that dataset, visualization type World Map.
  4. Configure:
  • Country Column: country
  • Country Field Type: Full name
  • Metric: SUM(metric)
  • Color by: Metric
  1. Expected: USA is colored; Canada and Mexico render in the default
    "no data" grey, identical to other countries that do not appear in the
    dataset.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot Bot added the viz:charts:map Related to Map charts label May 7, 2026
Copy link
Copy Markdown
Contributor

@bito-code-review bito-code-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #74c8a4

Actionable Suggestions - 1
  • superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.ts - 1
Review Details
  • Files reviewed - 2 · Commit Range: 22d80f1..22d80f1
    • superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.ts
    • superset-frontend/plugins/legacy-plugin-chart-world-map/test/WorldMap.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

: () => theme.colorBorder;

processedData = filteredData.map(d => ({
processedData = colorableData.map(d => ({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bubble rendering inconsistency

The diff incorrectly filters processedData to only include colorableData (where m1 is not null and not zero), which excludes countries from bubble rendering even when they have valid m2 values for bubble size. Bubbles should render for all countries in filteredData. Additionally, fillColor should use theme.colorBorder for null/zero m1 to prevent scale colors, rather than relying on the nullish coalescing operator.

Code suggestion
Check the AI-generated fix before applying
 -    processedData = colorableData.map(d => ({
 -      ...d,
 -      radius: radiusScale(Math.sqrt(d.m2)),
 -      fillColor: colorFn(d.m1) ?? theme.colorBorder,
 -    }));
 +    processedData = filteredData.map(d => ({
 +      ...d,
 +      radius: radiusScale(Math.sqrt(d.m2)),
 +      fillColor: (d.m1 != null && d.m1 !== 0) ? colorFn(d.m1) : theme.colorBorder,
 +    }));

Code Review Run #74c8a4


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant